//
//  STL_PlayerRecognizer.m
//  PanTest
//
//  Created by dllo on 16/4/8.
//  Copyright © 2016年 LZB. All rights reserved.
//

#import "STL_PlayerRecognizer.h"

@interface STL_PlayerRecognizer ()

//@property (nonatomic, strong) UIView *handleView;

@end

@implementation STL_PlayerRecognizer


- (void)handleSwipe:(UIPanGestureRecognizer *)recognizer withView:(UIView *)view{
    // 获得拖动的x值和y值
    CGPoint translation = [recognizer translationInView:view];
    // x的绝对值与y的绝对值的差值 用于倾斜滑动的时候判断滑动方向
    CGFloat subResult = fabs(translation.x) - fabs(translation.y);

        if (subResult > 0) {
            
            if (translation.x > 0) {
                if (self.startPanPoint.y < view.bounds.size.height / 2) {
                    self.direction = STLdirectionTopRight;
                } else {
                    self.direction = STLdirectionBottomRight;
                }
                
            } else {
                if (self.startPanPoint.y < view.bounds.size.height / 2) {
                    self.direction = STLdirectionTopLeft;
                } else {
                    self.direction = STLdirectionBottomLeft;
                }
                
            }
            [self.panDelegate recognizWithMoveDirection:self.direction withChangeValue:fabs(translation.x)];
            
        } else if (subResult < 0) {
            
            if (translation.y > 0) {
                self.direction = STLdirectionDown;
            } else if (translation.y < 0) {
                self.direction = STLdirectionUp;
            }
            [self.panDelegate recognizWithMoveDirection:self.direction withChangeValue:fabs(translation.y)];
        } else {
            self.direction = STLdirectionNone;
            [self.panDelegate recognizWithMoveDirection:self.direction withChangeValue:0];
        }
    
    
}


@end
